var orderNum = 0;
var cus_lat = new Array;
var cus_lng = new Array;
var cus_id = new Array;
var cus_nickname = new Array;
var cus_status = new Array;
var cus_credit = new Array;
//
var INIFORCUS = true;
var INIFORCUS2 = true;
var ADDINDEX = 0;
var cus_location = new Array;
var cus_markers = new Array;
var markerNum = 0;
var cus_icon = new google.maps.MarkerImage(
		'../images/person.png',
		new google.maps.Size(48,48)
		);
var cus_icon2 = new google.maps.MarkerImage(
		'../images/person2.png',
		new google.maps.Size(48,48)
		);
var map;
var tempCusLat;
var tempCusLng;

//content
var cus_content = new Array;
function testAddCus10(map){
	var cus_location0 = new google.maps.LatLng(39.88454, 116.30412);
	var cus_markers0 = new google.maps.Marker({
		position : cus_location0,
		title : 'hello',
		map : map,
		icon : cus_icon
	});	
	cus_markers0.setIcon(cus_icon2);
}

//STATUS CHAGE
function testAddCus(map){
	map = map;
//	cus_lat = [39.88454, 39.8603, 39.97215],
//	cus_lng = [116.30412, 116.45127, 116.26049],	
//	cus_nickname = ['luoxuan','baiyushi','senjia'],
//	cus_credit = [3,4,2],
//	cus_id = ['1380123094','1323485324', '13902834583'],
//	cus_status = [1,1,2]
	//var interv2 = setInterval(updateCusMarkers, 5000);
	var bal = true ; 
	setInterval(function(){
		//ADD MARKERS IN DIFFRENT AREA!
		ADDINDEX = ADDINDEX % 4;
		if(ADDINDEX == 3 && bal ==true){
			ADDINDEX-2;
			
		}
		cus_lat[markerNum] = cus_lat[ADDINDEX] + Math.random()*0.02;
		cus_lng[markerNum] = cus_lng[ADDINDEX] + Math.random()*0.02;
		tempCusLat = cus_lat[markerNum];
		tempCusLng = cus_lng[markerNum];
		//ADD MARKERS!
		cus_location[markerNum] = new google.maps.LatLng(tempCusLat, tempCusLng);
		cus_markers[markerNum] = new google.maps.Marker({
			position : cus_location[markerNum],
			title : 'hello',
			map : map,
			icon : cus_icon
		});	
		//ADD CONTENT!
		cus_content[markerNum] = '<div id="content">'+
	      '<div id="siteNotice">'+
	      '</div>'+
	      '<h1 id="firstHeading" class="firstHeading">CUSTOMER</h1>'+
	      '<div id="bodyContent">'+
	      '<p><b>cus_id: </b>' + cus_id[ADDINDEX] +',</b></p>'+
	      '<p><b>cus_name: </b>' + cus_nickname[ADDINDEX] +',</b></p>'+
	      '<p><b>cus_status: </b>' + cus_status[ADDINDEX] +',</b></p>'+
	      '<p><b>cus_credit: </b>' + cus_credit[ADDINDEX] +',</b></p>'+
	      '</div>'+
	      '</div>';
	//	console.log(markerNum);
		var cus_infowidow;
	    cus_infowidow = new google.maps.InfoWindow({
			content : cus_content[markerNum],
			position : cus_location[markerNum]
		});
	    //no maoding!
		google.maps.event.addListener(cus_markers[markerNum], 'click', function(){
			cus_infowidow.open(map)
		});
		ADDINDEX++;
		markerNum++;
	},3000)
	
	var ins = 0;
	var ins1 = 0;
	//1 area  Green
	setInterval(function(){
		//every 12100  green 
		var temp_markerNum = markerNum - 3; 
		cus_markers[temp_markerNum].setIcon(cus_icon2);
		
		// every 24200 delet

		var temp_markerNum = markerNum - 7; 
		if(temp_markerNum < markerNum&&temp_markerNum>0){
			cus_markers[temp_markerNum].setVisible(false);
		}
	},12100)
	
     //2 area few cus
	setInterval(function(){
		//every 12100  delet
		var temp_markerNum = markerNum -2; 
		cus_markers[temp_markerNum].setVisible(false);
	},12100)
	

	//3 area lot cus 
	setInterval(function(){
		//every 12100  delet
		if(ins % 2 == 0){
			var temp_markerNum = markerNum - 1; 
			cus_markers[temp_markerNum].setVisible(false);
		}
		ins ++;
	},24200)
	
	//0 area ,nomal customer
	setInterval(function(){
		//every 12100  delet
		var temp_markerNum = markerNum - 4; 
		cus_markers[temp_markerNum].setVisible(false);
	
		var temp_markerNum = markerNum - 8; 
		cus_markers[temp_markerNum].setVisible(false);
		var temp_markerNum = markerNum - 12;
		if(temp_markerNum < markerNum&&temp_markerNum>0){
			cus_markers[temp_markerNum].setVisible(false);
		}
	},36300)
}

function setAllMap(markers, map){
	for(var i = 0; i < markers.length; i++){
		markers[i].setMap(map);
	}
}